package com.hyperfix.simulator.senor;

import com.hyperfix.models.simulator.pojos.params.CasingPressure;
import com.hyperfix.utils.common.RandomUtil;


/**
 * @author JiangChunYu
 * 2024/3/15
 */
public class CasingPressureSenor implements InstantParamSenor {
    @Override
    public byte[] nextData() {
        double v = RandomUtil.nextRangeDouble(CasingPressure.getMaxValue(), CasingPressure.getMinValue());
        byte symbol = 0;
        if (v < 0) symbol = 1;
        int intPart = (int) v;
        int doublePart = (int) ((v - (int) v) * 100);
        byte[] data = new byte[2];
        data[0] = (byte) (intPart);
        data[1] = (byte) ((symbol << 7) | doublePart);
        return data;
    }
}
